package com.why.oss.controller;

import com.aliyun.oss.model.MultipartUpload;
import com.why.commonresults.Result;
import com.why.oss.service.ossService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @program: guli_parent
 * @description:
 * @author: @why
 * @create: 2021-01-30 11:55
 **/
@RestController
@RequestMapping("/eduoss/fileoss")
@CrossOrigin
public class ossController {

    @Autowired
    private ossService oss;

    /**
     * 文件上传
     * @return
     */
    @PostMapping
    public Result fileUploadByOss(MultipartFile  uploadFile){

        //将上传的地址返回
        String url = oss.uploadAvatar(uploadFile);
        return  Result.ok().data("url",url);
    }
}
